# -*- coding:utf-8 -*-
#! python3
from facecat import *

#绘制视图
#view:视图
#paint:绘图对象
#clipRect:区域
def onPaint(view, paint, clipRect):
	onPaintDefault(view, paint, clipRect)
	if view.viewName == "TabPage":
		paint.drawLine("rgb(255,0,0)", 1, 0, 100, 100, 300, 300)
		paint.drawLine("rgb(255,0,255)", 1, 2, 100, 300, 300, 100)
	elif view.viewName == "TabPage2":
		paint.drawRect("rgb(0,255,0)", 1, 0, 100, 100, 200, 200)
		paint.fillRect("rgb(0,255,255)", 250, 250, 350, 350)
	elif view.viewName == "TabPage3":
		paint.drawEllipse("rgb(0,255,255)", 1, 0, 100, 100, 200, 200)
		paint.fillEllipse("rgb(255,0,255)", 250, 250, 350, 350)
	elif view.viewName == "TabPage4":
		paint.drawText("FaceCat", "rgb(255,0,0)", "Default,30", 100, 100)
	elif view.viewName == "TabPage5":
		drawPoints = []
		drawPoints.append(FCPoint(100, 100))
		drawPoints.append(FCPoint(150, 120))
		drawPoints.append(FCPoint(130, 200))
		drawPoints.append(FCPoint(200, 200))
		drawPoints.append(FCPoint(250, 220))
		paint.drawPolyline("rgb(255,0,0)", 1, 0, drawPoints)
	elif view.viewName == "TabPage6":
		drawPoints = []
		drawPoints.append(FCPoint(100, 100))
		drawPoints.append(FCPoint(150, 120))
		drawPoints.append(FCPoint(200, 200))
		drawPoints.append(FCPoint(150, 200))
		paint.fillPolygon("rgb(0,0,255)", drawPoints)

gPaint = FCPaint() #创建绘图对象
gPaint.onPaint = onPaint 

#消息循环
def WndProc(hwnd,msg,wParam,lParam):
	return WndProcDefault(gPaint,hwnd,msg,wParam,lParam)

#初始化窗体
createMainWindow(gPaint, "facecat-py", WndProc)
current_file_path = os.path.abspath(__file__)
current_file_dir = os.path.dirname(current_file_path)
file0 = open(current_file_dir + "\\xml\\paintexample.xml", encoding="UTF-8")
xml = file0.read()
file0.close()
renderFaceCat(gPaint, xml)
showWindow(gPaint)